/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>

#include "sle_announce_server.h"
#include "sle_announce_callback_stub.h"

class SleAnnounceServerTest : public testing::Test {
public:
    static void SetUpTestCase();
    static void TearDownTestCase();
    void SetUp() override;
    void TearDown() override;

};
void SleAnnounceServerTest::SetUp(){}
void SleAnnounceServerTest::TearDown(){}
void SleAnnounceServerTest::SetUpTestCase(){}
void SleAnnounceServerTest::TearDownTestCase(){}

namespace OHOS {
namespace NearLink {
namespace SleStandard {

class SleAnnounceCallbackStubMock :public SleAnnounceCallbackStub{
    public:
        void OnAnnounceStateChange(uint8_t announceId, int32_t state, bool terminal){

        }
};


HWTEST_F(SleAnnounceServerTest, RegisterAnnounceCallback_001, testing::ext::TestSize.Level0)
{
    SleAnnounceServer sleServer;
    sptr<SleAnnounceCallbackStubMock> slecall = new SleAnnounceCallbackStubMock();

    SleErrorCode result = sleServer.RegisterAnnounceCallback(slecall);
    EXPECT_EQ(result, SLE_NO_ERROR);
}


HWTEST_F(SleAnnounceServerTest, UnregisterAnnounceCallback_001, testing::ext::TestSize.Level0)
{
    SleAnnounceServer sleServer;
    sptr<SleAnnounceCallbackStubMock> slecall = new SleAnnounceCallbackStubMock();

    SleErrorCode result = sleServer.RegisterAnnounceCallback(slecall);
    result = sleServer.UnregisterAnnounceCallback(slecall);
    EXPECT_EQ(result, SLE_NO_ERROR);
}


HWTEST_F(SleAnnounceServerTest, CreateAnnounceId_001, testing::ext::TestSize.Level0)
{
    SleAnnounceServer sleServer;
    sptr<SleAnnounceCallbackStubMock> slecall = new SleAnnounceCallbackStubMock();

    SleErrorCode result = sleServer.RegisterAnnounceCallback(slecall);
    uint8_t announceId = 2;
    result = sleServer.CreateAnnounceId(announceId);

    EXPECT_EQ(result, SLE_ERR_CHECKOUT_FAILED);
}


HWTEST_F(SleAnnounceServerTest, RemoveAnnounceId_001, testing::ext::TestSize.Level0)
{
    SleAnnounceServer sleServer;
    sptr<SleAnnounceCallbackStubMock> slecall = new SleAnnounceCallbackStubMock();

    SleErrorCode result = sleServer.RegisterAnnounceCallback(slecall);
    uint8_t announceId = 2;
    result = sleServer.CreateAnnounceId(announceId);
    result = sleServer.RemoveAnnounceId(announceId);

    EXPECT_EQ(result, SLE_ERR_CHECKOUT_FAILED);
}


HWTEST_F(SleAnnounceServerTest, StartAnnounce_001, testing::ext::TestSize.Level0)
{
    SleAnnounceServer sleServer;
    sptr<SleAnnounceCallbackStubMock> slecall = new SleAnnounceCallbackStubMock();

    SleErrorCode result = sleServer.RegisterAnnounceCallback(slecall);
    uint8_t announceId = 2;
    result = sleServer.CreateAnnounceId(announceId);

    AnnounceData data; AnnounceParam param;
    result = sleServer.StartAnnounce(announceId, data, param);
    EXPECT_EQ(result, SLE_ERR_CHECKOUT_FAILED);
}

HWTEST_F(SleAnnounceServerTest, StopAnnounce_001, testing::ext::TestSize.Level0)
{
    SleAnnounceServer sleServer;
    sptr<SleAnnounceCallbackStubMock> slecall = new SleAnnounceCallbackStubMock();

    SleErrorCode result = sleServer.RegisterAnnounceCallback(slecall);
    uint8_t announceId = 2;
    result = sleServer.CreateAnnounceId(announceId);

    result = sleServer.StopAnnounce(announceId);
    EXPECT_EQ(result, SLE_ERR_CHECKOUT_FAILED);
}


}}}